import SceneNavigator from "./SceneNavigator";

const {ccclass, property,executeInEditMode} = cc._decorator;

@ccclass
export default abstract class BaseScene extends cc.Component {
    /**
     * 自定义的加载完成之后回调
     * 加载场景后的回调
     */
    // abstract  _onLoaded(param);

    onLoad(){
        cc.view.setOrientation(cc.macro.ORIENTATION_LANDSCAPE);
        let size = cc.director.getScene().getChildByName("Canvas").getContentSize()
        let rate = size.width/size.height;
        rate = cc.view.getFrameSize().width /cc.view.getFrameSize().height;
        let canvas = cc.find("Canvas").getComponent(cc.Canvas);
        if(rate > cc.view.getDesignResolutionSize().width/cc.view.getDesignResolutionSize().height){
            canvas.fitHeight = false;
            canvas.fitWidth = true;
        }else{
            canvas.fitHeight = true;
            canvas.fitWidth = false;
        }

        //场景返回按钮
        let back = cc.find('Canvas/back');
        if(back){
            back.on(cc.Node.EventType.TOUCH_END, ()=>{
                SceneNavigator.goHome({});
            }, this);
        }
    }
}